package com.wzh.borrow.conf;

import com.wzh.borrow.vo.Rate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * @author WZH
 * @title: ProFilter
 * @projectName t1_1.22
 * @description:
 * @date 2022/1/24
 */
@Component
public class ProRuner implements ApplicationRunner {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("redis初始化");
        Rate rate = new Rate(2000,0.002);
        Rate rate2 = new Rate(20000,0.004);
        Rate rate3 = new Rate(50000,0.005);
        Rate rate4 = new Rate(100000,0.006);
        Rate rate5 = new Rate(1,0.05);
        ArrayList<Rate> rates = new ArrayList<>();
        rates.add(rate);
        rates.add(rate2);
        rates.add(rate3);
        rates.add(rate4);
        rates.add(rate5);
        redisTemplate.boundHashOps("map").put("rate",rates);
    }
}
